package win.smartown.mistyle.app.main;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import win.smartown.mistyle.OneButtonDialog;
import win.smartown.mistyle.TwoButtonDialog;
import win.smartown.mistyle.base.BaseActivity;
import win.smartown.mistyle.base.SuperActivity;
import win.smartown.mistyle.demo.R;

public class MainActivity extends BaseActivity implements View.OnClickListener {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setBaseView(R.layout.activity_main);
        findView(R.id.main_one).setOnClickListener(this);
        findView(R.id.main_two).setOnClickListener(this);
        findView(R.id.main_list).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.main_one:
                showOneButtonDialog();
                break;
            case R.id.main_two:
                showTwoButtonDialog();
                break;
            case R.id.main_list:
                break;
        }
    }

    private void showOneButtonDialog() {
        final OneButtonDialog dialog = OneButtonDialog.newInstance("分享密码给朋友", "完成", R.layout.layout_one_button_dialog_content);
        dialog.setCallback(new OneButtonDialog.Callback() {
            @Override
            public void onContentViewCreated(View view) {

            }

            @Override
            public void onButtonClick() {
                dialog.dismiss();
            }
        });
        dialog.show(getSupportFragmentManager(), null);
    }

    private void showTwoButtonDialog() {
        final TwoButtonDialog dialog = TwoButtonDialog.newInstance("删除联系人", "取消", "删除", R.layout.layout_two_button_dialog_content);
        dialog.setCallback(new TwoButtonDialog.Callback() {
            @Override
            public void onContentViewCreated(View view) {
                TextView textView = (TextView) view.findViewById(R.id.content_text);
                textView.setText("确定要删除此联系人吗？");
            }

            @Override
            public void onLeftButtonClick() {
                dialog.dismiss();
            }

            @Override
            public void onRightButtonClick() {
                dialog.dismiss();
            }
        });
        dialog.show(getSupportFragmentManager(), null);
    }

}
